package com.spider.silence.main;

import com.spider.silence.downloader.ZuiChengduDownLoader;
import com.spider.silence.pool.ZuiChengduDownLoaderPool;
import com.spider.silence.utils.PropertiesUtil;
import com.spider.silence.worker.MaLaWorker;
import com.spider.silence.worker.MalaModuleWorker;
import com.spider.silence.worker.ZuiChengduWorker;
import org.apache.log4j.PropertyConfigurator;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by qiuhao on 2017/5/5.
 */
public class ZuiChengduMain {

    public static void main(String[] args) throws Exception{
        PropertyConfigurator.configure( PropertiesUtil.getLogPro());//初始化日志环境
        ZuiChengduDownLoaderPool downLoaderPool=ZuiChengduDownLoaderPool.getInstance();
        ZuiChengduDownLoader downLoader=(ZuiChengduDownLoader)downLoaderPool.fetchDownLoader(1000);
        downLoader.generateTask();
        //初始化任务完后把下载器放回下载器中
        downLoaderPool.releaseDownLoader(downLoader);
        //创建线程池
        ExecutorService pool =  Executors.newFixedThreadPool(3000);

        for(int i=0;i<Integer.valueOf(PropertiesUtil.getVal("ZuiChengDu.WorkerCount"));i++){
            pool.execute(new ZuiChengduWorker());
        }
    }
}
